﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Warehouse.ErrorCord;
using Warehouse.Read.Api.Actions.Command.WarehouseCategory;
using Warehouse.Read.Api.DTO;

namespace Warehouse.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WarehouseController : ControllerBase
    {
        private readonly IMediator mediator;

        public WarehouseController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 仓库显示查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<APIPaging<WarehouseDTO>>> getwareShow([FromQuery]GetShowWareCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 仓库类别显示查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<APIResult<APIPaging<Warehouse.Domain.WarehouseCategory>>> getwareTypeShow([FromQuery
            ]GetWarehouseCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 树形结构查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<TreeDTO>>> GetTree([FromQuery]GetTreeCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 下拉框显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Warehouse.Domain.WarehouseCategory>>> GettypeShow([FromQuery]GetTypeCommand request)
        {
            return await mediator.Send(request);
        }
    }

}
